<template>
  <Dialog :title="dialogTitle" v-model="dialogVisible">
    <el-form
      ref="formRef"
      :model="formData"
      :rules="formRules"
      label-width="100px"
      v-loading="formLoading"
    >
      <el-form-item label="BOM No" prop="bomNo">
        <el-input v-model="formData.bomNo" placeholder="请输入BOM No" />
      </el-form-item>
	  <el-form-item label="客户" prop="customerId">
	    <el-input v-model="formData.customerId" placeholder="客户id" />
	  </el-form-item>
	  <el-form-item label="客户名称" prop="customerId">
	    <el-select v-model="formData.customerId" placeholder="请选择客户" clearable @change="handleCustomerChange">
	      <el-option
	        v-for="item in customerList"
	        :key="item.id"
	        :label="item.name"
	        :value="item.id"
	      />
	    </el-select>
	  </el-form-item>
      <el-form-item label="停用" prop="isStop">
        <el-radio-group v-model="formData.isStop">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="内部订单id" prop="internalOrderId">
        <el-input v-model="formData.internalOrderId" placeholder="请输入内部订单id" />
      </el-form-item>
      <el-form-item label="内部订单号" prop="internalOrderNo">
        <el-input v-model="formData.internalOrderNo" placeholder="请输入内部订单号" />
      </el-form-item>
      <el-form-item label="生产单号" prop="productionOrderNo">
        <el-input v-model="formData.productionOrderNo" placeholder="请输入生产单号" />
      </el-form-item>
      <el-form-item label="订单日期" prop="orderDate">
        <el-date-picker
          v-model="formData.orderDate"
          type="date"
          value-format="x"
          placeholder="选择订单日期"
        />
      </el-form-item>
      <el-form-item label="交货日期" prop="deliveryDate">
        <el-date-picker
          v-model="formData.deliveryDate"
          type="date"
          value-format="x"
          placeholder="选择交货日期"
        />
      </el-form-item>
      <el-form-item label="订单类型" prop="orderType">
        <el-input v-model="formData.orderType" placeholder="请输入订单类型" />
      </el-form-item>
      <el-form-item label="报价单位" prop="quotationUnit">
        <el-select v-model="formData.quotationUnit" placeholder="请选择报价单位">
          <el-option
            v-for="dict in getStrDictOptions(DICT_TYPE.BOM_PRICING_UNIT)"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="客户采购单号ID" prop="customerPurchaseOrderId">
        <el-input v-model="formData.customerPurchaseOrderId" placeholder="请输入客户采购单号ID" />
      </el-form-item>
      <el-form-item label="客户采购单号(订单号)" prop="customerPurchaseOrderNo">
        <el-input v-model="formData.customerPurchaseOrderNo" placeholder="请输入客户采购单号(订单号)" />
      </el-form-item>
      <el-form-item label="货号" prop="productCode">
        <el-input v-model="formData.productCode" placeholder="请输入货号" />
      </el-form-item>
      <el-form-item label="品名" prop="productName">
        <el-input v-model="formData.productName" placeholder="请输入品名" />
      </el-form-item>
      <el-form-item label="品名2" prop="productName2">
        <el-input v-model="formData.productName2" placeholder="请输入品名2" />
      </el-form-item>
      <el-form-item label="款型编号" prop="styleCode">
        <el-input v-model="formData.styleCode" placeholder="请输入款型编号" />
      </el-form-item>
      <el-form-item label="箱型ID" prop="boxTypeId">
        <el-input v-model="formData.boxTypeId" placeholder="请输入箱型ID" />
      </el-form-item>
      <el-form-item label="箱型名称" prop="boxTypeName">
        <el-input v-model="formData.boxTypeName" placeholder="请输入箱型名称" />
      </el-form-item>
	  <el-form-item label="箱型" prop="boxTypeId">
	    <el-select v-model="formData.boxTypeId" placeholder="请选择箱型" clearable @change="handleBoxTypeChange">
	      <el-option
	        v-for="item in boxTypeList"
	        :key="item.id"
	        :label="item.productTypeName"
	        :value="item.id"
	      />
	    </el-select>
	  </el-form-item>
      <el-form-item label="材质ID" prop="materialId">
        <el-input v-model="formData.materialId" placeholder="请输入材质ID" />
      </el-form-item>
      <el-form-item label="材质编号" prop="materialCode">
        <el-input v-model="formData.materialCode" placeholder="请输入材质编号" />
      </el-form-item>
      <el-form-item label="材质名称" prop="materialName">
        <el-input v-model="formData.materialName" placeholder="请输入材质名称" />
      </el-form-item>
	  <el-form-item label="材质名称" prop="materialId">
	    <el-select v-model="formData.materialId" placeholder="请选择材质" clearable @change="handleMaterialChange">
	      <el-option
	        v-for="item in materialList"
	        :key="item.id"
	        :label="item.materialName"
	        :value="item.id"
	      />
	    </el-select>
	  </el-form-item>
      <el-form-item label="生产材质ID" prop="productionMaterialId">
        <el-input v-model="formData.productionMaterialId" placeholder="请输入生产材质ID" />
      </el-form-item>
      <el-form-item label="生产材质编号" prop="productionMaterialCode">
        <el-input v-model="formData.productionMaterialCode" placeholder="请输入生产材质编号" />
      </el-form-item>
      <el-form-item label="生产材质名称" prop="productionMaterialName">
        <el-input v-model="formData.productionMaterialName" placeholder="请输入生产材质名称" />
      </el-form-item>
	  <el-form-item label="生产材质名称" prop="productionMaterialId">
	    <el-select v-model="formData.productionMaterialId" placeholder="请选择材质" clearable @change="handleProductMaterialChange">
	      <el-option
	        v-for="item in materialList"
	        :key="item.id"
	        :label="item.materialName"
	        :value="item.id"
	      />
	    </el-select>
	  </el-form-item>
      <el-form-item label="订单长" prop="orderLength">
        <el-input v-model="formData.orderLength" placeholder="请输入订单长" />
      </el-form-item>
      <el-form-item label="订单宽" prop="orderWidth">
        <el-input v-model="formData.orderWidth" placeholder="请输入订单宽" />
      </el-form-item>
      <el-form-item label="订单高" prop="orderHeight">
        <el-input v-model="formData.orderHeight" placeholder="请输入订单高" />
      </el-form-item>
      <el-form-item label="单位" prop="unit">
        <el-input v-model="formData.unit" placeholder="请输入单位" />
      </el-form-item>
      <el-form-item label="订单规格" prop="orderSpecification">
        <el-input v-model="formData.orderSpecification" placeholder="请输入订单规格" />
      </el-form-item>
      <el-form-item label="订单数" prop="orderQuantity">
        <el-input v-model="formData.orderQuantity" placeholder="请输入订单数" />
      </el-form-item>
      <el-form-item label="备品数" prop="sparePartsQuantity">
        <el-input v-model="formData.sparePartsQuantity" placeholder="请输入备品数" />
      </el-form-item>
      <el-form-item label="生产数" prop="productionQuantity">
        <el-input v-model="formData.productionQuantity" placeholder="请输入生产数" />
      </el-form-item>
      <el-form-item label="片接方式" prop="pieceAttachmentMethod">
        <el-select v-model="formData.pieceAttachmentMethod" placeholder="请选择片接方式">
          <el-option
            v-for="dict in getStrDictOptions(DICT_TYPE.PIECE_ATTACHMENT_METHOD)"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="是否客户特价" prop="isCustomerSpecialPrice">
        <el-radio-group v-model="formData.isCustomerSpecialPrice">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="面积报价" prop="areaQuotation">
        <el-input v-model="formData.areaQuotation" placeholder="请输入面积报价" />
      </el-form-item>
      <el-form-item label="单价" prop="unitPrice">
        <el-input v-model="formData.unitPrice" placeholder="请输入单价" />
      </el-form-item>
      <el-form-item label="体积" prop="volume">
        <el-input v-model="formData.volume" placeholder="请输入体积" />
      </el-form-item>
      <el-form-item label="排产数" prop="productionPlanQuantity">
        <el-input v-model="formData.productionPlanQuantity" placeholder="请输入排产数" />
      </el-form-item>
      <el-form-item label="入库数" prop="warehouseInQuantity">
        <el-input v-model="formData.warehouseInQuantity" placeholder="请输入入库数" />
      </el-form-item>
      <el-form-item label="送货数" prop="deliveryQuantity">
        <el-input v-model="formData.deliveryQuantity" placeholder="请输入送货数" />
      </el-form-item>
      <el-form-item label="印刷颜色" prop="printColor">
        <el-input v-model="formData.printColor" placeholder="请输入印刷颜色" />
      </el-form-item>
      <el-form-item label="报价单ID" prop="quotationId">
        <el-input v-model="formData.quotationId" placeholder="请输入报价单ID" />
      </el-form-item>
      <el-form-item label="报价单号" prop="quotationNo">
        <el-input v-model="formData.quotationNo" placeholder="请输入报价单号" />
      </el-form-item>
      <el-form-item label="生产长" prop="productionLength">
        <el-input v-model="formData.productionLength" placeholder="请输入生产长" />
      </el-form-item>
      <el-form-item label="生产宽" prop="productionWidth">
        <el-input v-model="formData.productionWidth" placeholder="请输入生产宽" />
      </el-form-item>
      <el-form-item label="生产高" prop="productionHeight">
        <el-input v-model="formData.productionHeight" placeholder="请输入生产高" />
      </el-form-item>
      <el-form-item label="生产规格" prop="productionSpecification">
        <el-input v-model="formData.productionSpecification" placeholder="请输入生产规格" />
      </el-form-item>
      <el-form-item label="横切版号" prop="crossCuttingVersionNo">
        <el-input v-model="formData.crossCuttingVersionNo" placeholder="请输入横切版号" />
      </el-form-item>
      <el-form-item label="审核" prop="isApproved">
        <el-radio-group v-model="formData.isApproved">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="面积" prop="area">
        <el-input v-model="formData.area" placeholder="请输入面积" />
      </el-form-item>
      <el-form-item label="中止" prop="isTerminated">
        <el-radio-group v-model="formData.isTerminated">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="包装数" prop="packagingQuantity">
        <el-input v-model="formData.packagingQuantity" placeholder="请输入包装数" />
      </el-form-item>
      <el-form-item label="备注" prop="remark">
        <el-input v-model="formData.remark" placeholder="请输入备注" />
      </el-form-item>
      <el-form-item label="结单" prop="isFinalized">
        <el-radio-group v-model="formData.isFinalized">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="打印" prop="isPrinted">
        <el-radio-group v-model="formData.isPrinted">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="生产备注" prop="productionRemark">
        <el-input v-model="formData.productionRemark" placeholder="请输入生产备注" />
      </el-form-item>
      <el-form-item label="内外径" prop="innerOuterDiameter">
        <el-input v-model="formData.innerOuterDiameter" placeholder="请输入内外径" />
      </el-form-item>
      <el-form-item label="楞型" prop="flangeType">
        <el-select v-model="formData.flangeType" placeholder="请选择楞型">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="模切算料" prop="dieCuttingCalculation">
        <el-radio-group v-model="formData.dieCuttingCalculation">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="模板宽" prop="templateWidth">
        <el-input v-model="formData.templateWidth" placeholder="请输入模板宽" />
      </el-form-item>
      <el-form-item label="模板长" prop="templateLength">
        <el-input v-model="formData.templateLength" placeholder="请输入模板长" />
      </el-form-item>
      <el-form-item label="模数" prop="modulus">
        <el-input v-model="formData.modulus" placeholder="请输入模数" />
      </el-form-item>
      <el-form-item label="外协" prop="outsourcing">
        <el-input v-model="formData.outsourcing" placeholder="请输入外协" />
      </el-form-item>
      <el-form-item label="产品类型" prop="productType">
        <el-select v-model="formData.productType" placeholder="请选择产品类型">
          <el-option
            v-for="dict in getStrDictOptions(DICT_TYPE.CARDBOARD_PRODUCTION_PRODUCT_TYPE)"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="专色" prop="specialColor">
        <el-input v-model="formData.specialColor" placeholder="请输入专色" />
      </el-form-item>
      <el-form-item label="机台" prop="machine">
        <el-input v-model="formData.machine" placeholder="请输入机台" />
      </el-form-item>
      <el-form-item label="装钉方式" prop="nailingMethod">
        <el-input v-model="formData.nailingMethod" placeholder="请输入装钉方式" />
      </el-form-item>
      <el-form-item label="粘合方式" prop="adhesionMethod">
        <el-input v-model="formData.adhesionMethod" placeholder="请输入粘合方式" />
      </el-form-item>
      <el-form-item label="包装方式" prop="packagingMethod">
        <el-input v-model="formData.packagingMethod" placeholder="请输入包装方式" />
      </el-form-item>
      <el-form-item label="附配件" prop="accessories">
        <el-input v-model="formData.accessories" placeholder="请输入附配件" />
      </el-form-item>
      <el-form-item label="折数" prop="foldingNumber">
        <el-input v-model="formData.foldingNumber" placeholder="请输入折数" />
      </el-form-item>
      <el-form-item label="对裱类型" prop="laminationType">
        <el-select v-model="formData.laminationType" placeholder="请选择对裱类型">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="送货方式" prop="deliveryMethod">
        <el-input v-model="formData.deliveryMethod" placeholder="请输入送货方式" />
      </el-form-item>
      <el-form-item label="留版" prop="leaveVersion">
        <el-radio-group v-model="formData.leaveVersion">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="ctp" prop="ctp">
        <el-radio-group v-model="formData.ctp">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="新刀模" prop="newDiemold">
        <el-radio-group v-model="formData.newDiemold">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="旧刀模" prop="oldDiemold">
        <el-radio-group v-model="formData.oldDiemold">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="表面处理" prop="surfaceTreatment">
        <el-input v-model="formData.surfaceTreatment" placeholder="请输入表面处理" />
      </el-form-item>
      <el-form-item label="生产工艺" prop="productionProcess">
        <el-input v-model="formData.productionProcess" placeholder="请输入生产工艺" />
      </el-form-item>
      <el-form-item label="客户PO" prop="customerPo">
        <el-input v-model="formData.customerPo" placeholder="请输入客户PO" />
      </el-form-item>
      <el-form-item label="切角" prop="cutCorners">
        <el-radio-group v-model="formData.cutCorners">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="配比数" prop="proportionQuantity">
        <el-input v-model="formData.proportionQuantity" placeholder="请输入配比数" />
      </el-form-item>
      <el-form-item label="产品单位" prop="productUnit">
        <el-select v-model="formData.productUnit" placeholder="请选择产品单位">
          <el-option
            v-for="dict in getStrDictOptions(DICT_TYPE.VALUATION_UNIT)"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="子件" prop="subcomponent">
        <el-radio-group v-model="formData.subcomponent">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="序号" prop="serialNo">
        <el-input v-model="formData.serialNo" placeholder="请输入序号" />
      </el-form-item>
      <el-form-item label="项目号" prop="projectNo">
        <el-input v-model="formData.projectNo" placeholder="请输入项目号" />
      </el-form-item>
      <el-form-item label="客户材质" prop="customerMaterial">
        <el-input v-model="formData.customerMaterial" placeholder="请输入客户材质" />
      </el-form-item>
      <el-form-item label="产品描述" prop="productDescription">
        <el-input v-model="formData.productDescription" type="textarea" placeholder="请输入产品描述" />
      </el-form-item>
      <el-form-item label="产品备注1" prop="productRemark1">
        <el-input v-model="formData.productRemark1" placeholder="请输入产品备注1" />
      </el-form-item>
      <el-form-item label="产品备注2" prop="productRemark2">
        <el-input v-model="formData.productRemark2" placeholder="请输入产品备注2" />
      </el-form-item>
      <el-form-item label="产品备注3" prop="productRemark3">
        <el-input v-model="formData.productRemark3" placeholder="请输入产品备注3" />
      </el-form-item>
      <el-form-item label="产品备注4" prop="productRemark4">
        <el-input v-model="formData.productRemark4" placeholder="请输入产品备注4" />
      </el-form-item>
      <el-form-item label="产品备注5" prop="productRemark5">
        <el-input v-model="formData.productRemark5" placeholder="请输入产品备注5" />
      </el-form-item>
      <el-form-item label="钉条" prop="stapleBar">
        <el-input v-model="formData.stapleBar" placeholder="请输入钉条" />
      </el-form-item>
      <el-form-item label="加分" prop="addPoints">
        <el-input v-model="formData.addPoints" placeholder="请输入加分" />
      </el-form-item>
      <el-form-item label="外购" prop="isExternalPurchase">
        <el-radio-group v-model="formData.isExternalPurchase">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="生产工艺" prop="productionProcess2">
        <el-input v-model="formData.productionProcess2" placeholder="请输入生产工艺" />
      </el-form-item>
      <el-form-item label="套数" prop="sets">
        <el-input v-model="formData.sets" placeholder="请输入套数" />
      </el-form-item>
      <el-form-item label="厚度" prop="thickness">
        <el-input v-model="formData.thickness" placeholder="请输入厚度" />
      </el-form-item>
      <el-form-item label="单重" prop="unitWeight">
        <el-input v-model="formData.unitWeight" placeholder="请输入单重" />
      </el-form-item>
      <el-form-item label="天地盒" prop="isHeavenBox">
        <el-radio-group v-model="formData.isHeavenBox">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="天地盒高" prop="heavenBoxHeight">
        <el-input v-model="formData.heavenBoxHeight" placeholder="请输入天地盒高" />
      </el-form-item>
      <el-form-item label="天地盒长" prop="heavenBoxLength">
        <el-input v-model="formData.heavenBoxLength" placeholder="请输入天地盒长" />
      </el-form-item>
      <el-form-item label="天地盒宽" prop="heavenBoxWidth">
        <el-input v-model="formData.heavenBoxWidth" placeholder="请输入天地盒宽" />
      </el-form-item>
      <el-form-item label="金额" prop="amount">
        <el-input v-model="formData.amount" placeholder="请输入金额" />
      </el-form-item>
      <el-form-item label="套件ID" prop="setId">
        <el-input v-model="formData.setId" placeholder="请输入套件ID" />
      </el-form-item>
      <el-form-item label="套件名" prop="setName">
        <el-input v-model="formData.setName" placeholder="请输入套件名" />
      </el-form-item>
      <el-form-item label="主件ID" prop="mainItemId">
        <el-input v-model="formData.mainItemId" placeholder="请输入主件ID" />
      </el-form-item>
      <el-form-item label="主件名" prop="mainItemName">
        <el-input v-model="formData.mainItemName" placeholder="请输入主件名" />
      </el-form-item>
      <el-form-item label="其他备注" prop="otherRemark">
        <el-input v-model="formData.otherRemark" placeholder="请输入其他备注" />
      </el-form-item>
      <el-form-item label="尺寸/码段" prop="sizeSegment">
        <el-input v-model="formData.sizeSegment" placeholder="请输入尺寸/码段" />
      </el-form-item>
      <el-form-item label="多款类型" prop="multipleModelTypes">
        <el-input v-model="formData.multipleModelTypes" placeholder="请输入多款类型" />
      </el-form-item>
      <el-form-item label="内容" prop="content">
        <el-input v-model="formData.content" placeholder="请输入内容" />
      </el-form-item>
      <el-form-item label="印色" prop="printColor2">
        <el-input v-model="formData.printColor2" placeholder="请输入印色" />
      </el-form-item>
      <el-form-item label="做法" prop="process">
        <el-input v-model="formData.process" placeholder="请输入做法" />
      </el-form-item>
      <el-form-item label="其他" prop="other">
        <el-input v-model="formData.other" placeholder="请输入其他" />
      </el-form-item>
      <el-form-item label="模板宽2" prop="templateWidth2">
        <el-input v-model="formData.templateWidth2" placeholder="请输入模板宽2" />
      </el-form-item>
      <el-form-item label="模板长2" prop="templateLength2">
        <el-input v-model="formData.templateLength2" placeholder="请输入模板长2" />
      </el-form-item>
      <el-form-item label="模数2" prop="modulus2">
        <el-input v-model="formData.modulus2" placeholder="请输入模数2" />
      </el-form-item>
      <el-form-item label="客户手工单号" prop="customerManualOrderNo">
        <el-input v-model="formData.customerManualOrderNo" placeholder="请输入客户手工单号" />
      </el-form-item>
      <el-form-item label="总面积" prop="totalArea">
        <el-input v-model="formData.totalArea" placeholder="请输入总面积" />
      </el-form-item>
      <el-form-item label="包装方式" prop="packagingMethod2">
        <el-input v-model="formData.packagingMethod2" placeholder="请输入包装方式" />
      </el-form-item>
      <el-form-item label="附加费用" prop="additionalCost">
        <el-input v-model="formData.additionalCost" placeholder="请输入附加费用" />
      </el-form-item>
      <el-form-item label="参数1" prop="parameter1">
        <el-input v-model="formData.parameter1" placeholder="请输入参数1" />
      </el-form-item>
      <el-form-item label="参数2" prop="parameter2">
        <el-input v-model="formData.parameter2" placeholder="请输入参数2" />
      </el-form-item>
      <el-form-item label="参数3" prop="parameter3">
        <el-input v-model="formData.parameter3" placeholder="请输入参数3" />
      </el-form-item>
      <el-form-item label="参数4" prop="parameter4">
        <el-input v-model="formData.parameter4" placeholder="请输入参数4" />
      </el-form-item>
      <el-form-item label="参数5" prop="parameter5">
        <el-input v-model="formData.parameter5" placeholder="请输入参数5" />
      </el-form-item>
      <el-form-item label="参数6" prop="parameter6">
        <el-input v-model="formData.parameter6" placeholder="请输入参数6" />
      </el-form-item>
      <el-form-item label="参数7" prop="parameter7">
        <el-input v-model="formData.parameter7" placeholder="请输入参数7" />
      </el-form-item>
      <el-form-item label="参数8" prop="parameter8">
        <el-input v-model="formData.parameter8" placeholder="请输入参数8" />
      </el-form-item>
      <el-form-item label="参数9" prop="parameter9">
        <el-input v-model="formData.parameter9" placeholder="请输入参数9" />
      </el-form-item>
      <el-form-item label="参数10" prop="parameter10">
        <el-input v-model="formData.parameter10" placeholder="请输入参数10" />
      </el-form-item>
      <el-form-item label="同款" prop="isSameModel">
        <el-radio-group v-model="formData.isSameModel">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="拼单号" prop="orderNumber">
        <el-input v-model="formData.orderNumber" placeholder="请输入拼单号" />
      </el-form-item>
      <el-form-item label="BOM序号" prop="bomSequenceNumber">
        <el-input v-model="formData.bomSequenceNumber" placeholder="请输入BOM序号" />
      </el-form-item>
      <el-form-item label="BOM层级" prop="bomLevel">
        <el-input v-model="formData.bomLevel" placeholder="请输入BOM层级" />
      </el-form-item>
      <el-form-item label="未送货数" prop="unshippedQuantity">
        <el-input v-model="formData.unshippedQuantity" placeholder="请输入未送货数" />
      </el-form-item>
      <el-form-item label="未送货数" prop="unsentQuantity">
        <el-input v-model="formData.unsentQuantity" placeholder="请输入未送货数" />
      </el-form-item>
      <el-form-item label="总体积" prop="totalVolume">
        <el-input v-model="formData.totalVolume" placeholder="请输入总体积" />
      </el-form-item>
      <el-form-item label="印刷版号" prop="printVersionNo">
        <el-input v-model="formData.printVersionNo" placeholder="请输入印刷版号" />
      </el-form-item>
      <el-form-item label="BOM是否重新计价" prop="bomRecalculation">
        <el-radio-group v-model="formData.bomRecalculation">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="材质类型ID" prop="materialTypeId">
        <el-input v-model="formData.materialTypeId" placeholder="请输入材质类型ID" />
      </el-form-item>
      <el-form-item label="材质类型" prop="materialType">
        <el-select v-model="formData.materialType" placeholder="请选择材质类型">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="制版完成" prop="completionOfVersion">
        <el-radio-group v-model="formData.completionOfVersion">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="加损耗" prop="addLoss">
        <el-radio-group v-model="formData.addLoss">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="参数11" prop="parameter11">
        <el-input v-model="formData.parameter11" placeholder="请输入参数11" />
      </el-form-item>
      <el-form-item label="参数12" prop="parameter12">
        <el-input v-model="formData.parameter12" placeholder="请输入参数12" />
      </el-form-item>
      <el-form-item label="参数13" prop="parameter13">
        <el-input v-model="formData.parameter13" placeholder="请输入参数13" />
      </el-form-item>
      <el-form-item label="参数14" prop="parameter14">
        <el-input v-model="formData.parameter14" placeholder="请输入参数14" />
      </el-form-item>
      <el-form-item label="参数15" prop="parameter15">
        <el-input v-model="formData.parameter15" placeholder="请输入参数15" />
      </el-form-item>
      <el-form-item label="参数16" prop="parameter16">
        <el-input v-model="formData.parameter16" placeholder="请输入参数16" />
      </el-form-item>
      <el-form-item label="参数17" prop="parameter17">
        <el-input v-model="formData.parameter17" placeholder="请输入参数17" />
      </el-form-item>
      <el-form-item label="参数18" prop="parameter18">
        <el-input v-model="formData.parameter18" placeholder="请输入参数18" />
      </el-form-item>
      <el-form-item label="参数19" prop="parameter19">
        <el-input v-model="formData.parameter19" placeholder="请输入参数19" />
      </el-form-item>
      <el-form-item label="参数20" prop="parameter20">
        <el-input v-model="formData.parameter20" placeholder="请输入参数20" />
      </el-form-item>
      <el-form-item label="单价附加费" prop="unitPriceAdditionalFee">
        <el-input v-model="formData.unitPriceAdditionalFee" placeholder="请输入单价附加费" />
      </el-form-item>
      <el-form-item label="纸板单号" prop="paperboardOrderNo">
        <el-input v-model="formData.paperboardOrderNo" placeholder="请输入纸板单号" />
      </el-form-item>
      <el-form-item label="纸板单号ID" prop="paperboardOrderId">
        <el-input v-model="formData.paperboardOrderId" placeholder="请输入纸板单号ID" />
      </el-form-item>
      <el-form-item label="微信推送" prop="wechatPush">
        <el-radio-group v-model="formData.wechatPush">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="成本单价" prop="costPrice">
        <el-input v-model="formData.costPrice" placeholder="请输入成本单价" />
      </el-form-item>
      <el-form-item label="面积成本单价" prop="areaCostPrice">
        <el-input v-model="formData.areaCostPrice" placeholder="请输入面积成本单价" />
      </el-form-item>
      <el-form-item label="折扣" prop="discount">
        <el-input v-model="formData.discount" placeholder="请输入折扣" />
      </el-form-item>
      <el-form-item label="毛板重量" prop="grossBoardWeight">
        <el-input v-model="formData.grossBoardWeight" placeholder="请输入毛板重量" />
      </el-form-item>
      <el-form-item label="用库存" prop="useInventory">
        <el-radio-group v-model="formData.useInventory">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="备品百分比" prop="sparePartsPercentage">
        <el-input v-model="formData.sparePartsPercentage" placeholder="请输入备品百分比" />
      </el-form-item>
      <el-form-item label="利润率" prop="profitMargin">
        <el-input v-model="formData.profitMargin" placeholder="请输入利润率" />
      </el-form-item>
      <el-form-item label="优惠" prop="discountPrice">
        <el-input v-model="formData.discountPrice" placeholder="请输入优惠" />
      </el-form-item>
      <el-form-item label="面积单价" prop="areaUnitPrice">
        <el-input v-model="formData.areaUnitPrice" placeholder="请输入面积单价" />
      </el-form-item>
      <el-form-item label="总重" prop="totalWeight">
        <el-input v-model="formData.totalWeight" placeholder="请输入总重" />
      </el-form-item>
      <el-form-item label="单价加价" prop="unitPriceMarkup">
        <el-input v-model="formData.unitPriceMarkup" placeholder="请输入单价加价" />
      </el-form-item>
      <el-form-item label="自定义克重" prop="customWeight">
        <el-input v-model="formData.customWeight" placeholder="请输入自定义克重" />
      </el-form-item>
      <el-form-item label="标记1" prop="tag1">
        <el-radio-group v-model="formData.tag1">
          <el-radio value="1">请选择字典生成</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="标记2" prop="tag2">
        <el-radio-group v-model="formData.tag2">
          <el-radio value="1">请选择字典生成</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="标记3" prop="tag3">
        <el-radio-group v-model="formData.tag3">
          <el-radio value="1">请选择字典生成</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="标记4" prop="tag4">
        <el-radio-group v-model="formData.tag4">
          <el-radio value="1">请选择字典生成</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="标记5" prop="tag5">
        <el-radio-group v-model="formData.tag5">
          <el-radio value="1">请选择字典生成</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="送货地址" prop="deliveryAddress">
        <el-input v-model="formData.deliveryAddress" placeholder="请输入送货地址" />
      </el-form-item>
      <el-form-item label="送货区域" prop="deliveryRegion">
        <el-input v-model="formData.deliveryRegion" placeholder="请输入送货区域" />
      </el-form-item>
      <el-form-item label="件数" prop="quantity">
        <el-input v-model="formData.quantity" placeholder="请输入件数" />
      </el-form-item>
      <el-form-item label="附加成本单价" prop="additionalCostUnitPrice">
        <el-input v-model="formData.additionalCostUnitPrice" placeholder="请输入附加成本单价" />
      </el-form-item>
      <el-form-item label="原料成本占比" prop="rawMaterialCostRatio">
        <el-input v-model="formData.rawMaterialCostRatio" placeholder="请输入原料成本占比" />
      </el-form-item>
      <el-form-item label="平方差价" prop="squarePriceDifference">
        <el-input v-model="formData.squarePriceDifference" placeholder="请输入平方差价" />
      </el-form-item>
      <el-form-item label="整版" prop="fullPage">
        <el-radio-group v-model="formData.fullPage">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="散版" prop="splitPage">
        <el-radio-group v-model="formData.splitPage">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="旧版" prop="oldVersion">
        <el-radio-group v-model="formData.oldVersion">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="旧改" prop="oldModified">
        <el-radio-group v-model="formData.oldModified">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="新版" prop="newVersion">
        <el-radio-group v-model="formData.newVersion">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="平轧" prop="flatRolling">
        <el-radio-group v-model="formData.flatRolling">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="圆轧" prop="roundRolling">
        <el-radio-group v-model="formData.roundRolling">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="旧模" prop="oldDieCutting">
        <el-radio-group v-model="formData.oldDieCutting">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="旧模改" prop="oldDieCuttingModified">
        <el-radio-group v-model="formData.oldDieCuttingModified">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="新模" prop="newDieCutting">
        <el-radio-group v-model="formData.newDieCutting">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="选择1" prop="choice1">
        <el-radio-group v-model="formData.choice1">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="选择2" prop="choice2">
        <el-radio-group v-model="formData.choice2">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="选择3" prop="choice3">
        <el-radio-group v-model="formData.choice3">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="选择4" prop="choice4">
        <el-radio-group v-model="formData.choice4">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="不上传文件" prop="noUploadFile">
        <el-radio-group v-model="formData.noUploadFile">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="倒摊面积单价" prop="downSpreadAreaUnitPrice">
        <el-input v-model="formData.downSpreadAreaUnitPrice" placeholder="请输入倒摊面积单价" />
      </el-form-item>
      <el-form-item label="压线" prop="pressLine">
        <el-input v-model="formData.pressLine" placeholder="请输入压线" />
      </el-form-item>
      <el-form-item label="纵压压线" prop="verticalPressLine">
        <el-input v-model="formData.verticalPressLine" placeholder="请输入纵压压线" />
      </el-form-item>
      <el-form-item label="财务审核" prop="financialApproval">
        <el-radio-group v-model="formData.financialApproval">
          <el-radio
            v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
            :key="dict.value"
            :label="dict.value"
          >
            {{ dict.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="财务审核时间" prop="financialApprovalTime">
        <el-date-picker
          v-model="formData.financialApprovalTime"
          type="date"
          value-format="x"
          placeholder="选择财务审核时间"
        />
      </el-form-item>
      <el-form-item label="财务审核人" prop="financialApprover">
        <el-input v-model="formData.financialApprover" placeholder="请输入财务审核人" />
      </el-form-item>
    </el-form>
    <template #footer>
      <el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
      <el-button @click="dialogVisible = false">取 消</el-button>
    </template>
  </Dialog>
</template>
<script setup lang="ts">
import { getStrDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
import { SaleBomApi, SaleBomVO } from '@/api/erp/salebom'

/** ERP销售管理-BOM 表单 */
defineOptions({ name: 'SaleBomForm' })

const { t } = useI18n() // 国际化
const message = useMessage() // 消息弹窗

const dialogVisible = ref(false) // 弹窗的是否展示
const dialogTitle = ref('') // 弹窗的标题
const formLoading = ref(false) // 表单的加载中：1）修改时的数据加载；2）提交的按钮禁用
const formType = ref('') // 表单的类型：create - 新增；update - 修改
const formData = ref({
  id: undefined,
  bomNo: undefined,
  customerId: undefined,
  customerNumber: undefined,
  customerName: undefined,
  isStop: undefined,
  internalOrderId: undefined,
  internalOrderNo: undefined,
  productionOrderNo: undefined,
  orderDate: undefined,
  deliveryDate: undefined,
  orderType: undefined,
  quotationUnit: undefined,
  customerPurchaseOrderId: undefined,
  customerPurchaseOrderNo: undefined,
  productCode: undefined,
  productName: undefined,
  productName2: undefined,
  styleCode: undefined,
  boxTypeId: undefined,
  boxTypeName: undefined,
  materialId: undefined,
  materialCode: undefined,
  materialName: undefined,
  productionMaterialId: undefined,
  productionMaterialCode: undefined,
  productionMaterialName: undefined,
  orderLength: undefined,
  orderWidth: undefined,
  orderHeight: undefined,
  unit: undefined,
  orderSpecification: undefined,
  orderQuantity: undefined,
  sparePartsQuantity: undefined,
  productionQuantity: undefined,
  pieceAttachmentMethod: undefined,
  isCustomerSpecialPrice: undefined,
  areaQuotation: undefined,
  unitPrice: undefined,
  volume: undefined,
  productionPlanQuantity: undefined,
  warehouseInQuantity: undefined,
  deliveryQuantity: undefined,
  printColor: undefined,
  quotationId: undefined,
  quotationNo: undefined,
  productionLength: undefined,
  productionWidth: undefined,
  productionHeight: undefined,
  productionSpecification: undefined,
  crossCuttingVersionNo: undefined,
  isApproved: undefined,
  area: undefined,
  isTerminated: undefined,
  packagingQuantity: undefined,
  remark: undefined,
  isFinalized: undefined,
  isPrinted: undefined,
  productionRemark: undefined,
  innerOuterDiameter: undefined,
  flangeType: undefined,
  dieCuttingCalculation: undefined,
  templateWidth: undefined,
  templateLength: undefined,
  modulus: undefined,
  outsourcing: undefined,
  productType: undefined,
  specialColor: undefined,
  machine: undefined,
  nailingMethod: undefined,
  adhesionMethod: undefined,
  packagingMethod: undefined,
  accessories: undefined,
  foldingNumber: undefined,
  laminationType: undefined,
  deliveryMethod: undefined,
  leaveVersion: undefined,
  ctp: undefined,
  newDiemold: undefined,
  oldDiemold: undefined,
  surfaceTreatment: undefined,
  productionProcess: undefined,
  customerPo: undefined,
  cutCorners: undefined,
  proportionQuantity: undefined,
  productUnit: undefined,
  subcomponent: undefined,
  serialNo: undefined,
  projectNo: undefined,
  customerMaterial: undefined,
  productDescription: undefined,
  productRemark1: undefined,
  productRemark2: undefined,
  productRemark3: undefined,
  productRemark4: undefined,
  productRemark5: undefined,
  stapleBar: undefined,
  addPoints: undefined,
  isExternalPurchase: undefined,
  productionProcess2: undefined,
  sets: undefined,
  thickness: undefined,
  unitWeight: undefined,
  isHeavenBox: undefined,
  heavenBoxHeight: undefined,
  heavenBoxLength: undefined,
  heavenBoxWidth: undefined,
  amount: undefined,
  setId: undefined,
  setName: undefined,
  mainItemId: undefined,
  mainItemName: undefined,
  otherRemark: undefined,
  sizeSegment: undefined,
  multipleModelTypes: undefined,
  content: undefined,
  printColor2: undefined,
  process: undefined,
  other: undefined,
  templateWidth2: undefined,
  templateLength2: undefined,
  modulus2: undefined,
  customerManualOrderNo: undefined,
  totalArea: undefined,
  packagingMethod2: undefined,
  additionalCost: undefined,
  parameter1: undefined,
  parameter2: undefined,
  parameter3: undefined,
  parameter4: undefined,
  parameter5: undefined,
  parameter6: undefined,
  parameter7: undefined,
  parameter8: undefined,
  parameter9: undefined,
  parameter10: undefined,
  isSameModel: undefined,
  orderNumber: undefined,
  bomSequenceNumber: undefined,
  bomLevel: undefined,
  unshippedQuantity: undefined,
  unsentQuantity: undefined,
  totalVolume: undefined,
  printVersionNo: undefined,
  bomRecalculation: undefined,
  materialTypeId: undefined,
  materialType: undefined,
  completionOfVersion: undefined,
  addLoss: undefined,
  parameter11: undefined,
  parameter12: undefined,
  parameter13: undefined,
  parameter14: undefined,
  parameter15: undefined,
  parameter16: undefined,
  parameter17: undefined,
  parameter18: undefined,
  parameter19: undefined,
  parameter20: undefined,
  unitPriceAdditionalFee: undefined,
  paperboardOrderNo: undefined,
  paperboardOrderId: undefined,
  wechatPush: undefined,
  costPrice: undefined,
  areaCostPrice: undefined,
  discount: undefined,
  grossBoardWeight: undefined,
  useInventory: undefined,
  sparePartsPercentage: undefined,
  profitMargin: undefined,
  discountPrice: undefined,
  areaUnitPrice: undefined,
  totalWeight: undefined,
  unitPriceMarkup: undefined,
  customWeight: undefined,
  tag1: undefined,
  tag2: undefined,
  tag3: undefined,
  tag4: undefined,
  tag5: undefined,
  deliveryAddress: undefined,
  deliveryRegion: undefined,
  quantity: undefined,
  additionalCostUnitPrice: undefined,
  rawMaterialCostRatio: undefined,
  squarePriceDifference: undefined,
  fullPage: undefined,
  splitPage: undefined,
  oldVersion: undefined,
  oldModified: undefined,
  newVersion: undefined,
  flatRolling: undefined,
  roundRolling: undefined,
  oldDieCutting: undefined,
  oldDieCuttingModified: undefined,
  newDieCutting: undefined,
  choice1: undefined,
  choice2: undefined,
  choice3: undefined,
  choice4: undefined,
  noUploadFile: undefined,
  downSpreadAreaUnitPrice: undefined,
  pressLine: undefined,
  verticalPressLine: undefined,
  financialApproval: undefined,
  financialApprovalTime: undefined,
  financialApprover: undefined
})
const formRules = reactive({
  isStop: [{ required: true, message: '停用不能为空', trigger: 'blur' }]
  // internalOrderId: [{ required: true, message: '内部订单id不能为空', trigger: 'blur' }],
  // internalOrderNo: [{ required: true, message: '内部订单号不能为空', trigger: 'blur' }]
})
const formRef = ref() // 表单 Ref

/** 打开弹窗 */
const open = async (type: string, id?: number) => {
  dialogVisible.value = true
  dialogTitle.value = t('action.' + type)
  formType.value = type
  resetForm()
  // 修改时，设置数据
  if (id) {
    formLoading.value = true
    try {
      formData.value = await SaleBomApi.getSaleBom(id)
    } finally {
      formLoading.value = false
    }
  }
}
defineExpose({ open }) // 提供 open 方法，用于打开弹窗

/** 提交表单 */
const emit = defineEmits(['success']) // 定义 success 事件，用于操作成功后的回调
const submitForm = async () => {
  // 校验表单
  await formRef.value.validate()
  // 提交请求
  formLoading.value = true
  try {
    const data = formData.value as unknown as SaleBomVO
    if (formType.value === 'create') {
      await SaleBomApi.createSaleBom(data)
      message.success(t('common.createSuccess'))
    } else {
      await SaleBomApi.updateSaleBom(data)
      message.success(t('common.updateSuccess'))
    }
    dialogVisible.value = false
    // 发送操作成功的事件
    emit('success')
  } finally {
    formLoading.value = false
  }
}

/** 重置表单 */
const resetForm = () => {
  formData.value = {
    id: undefined,
    bomNo: undefined,
	customerId: undefined,
	customerNumber: undefined,
	customerName: undefined,
    isStop: undefined,
    internalOrderId: undefined,
    internalOrderNo: undefined,
    productionOrderNo: undefined,
    orderDate: undefined,
    deliveryDate: undefined,
    orderType: undefined,
    quotationUnit: undefined,
    customerPurchaseOrderId: undefined,
    customerPurchaseOrderNo: undefined,
    productCode: undefined,
    productName: undefined,
    productName2: undefined,
    styleCode: undefined,
    boxTypeId: undefined,
    boxTypeName: undefined,
    materialId: undefined,
    materialCode: undefined,
    materialName: undefined,
    productionMaterialId: undefined,
    productionMaterialCode: undefined,
    productionMaterialName: undefined,
    orderLength: undefined,
    orderWidth: undefined,
    orderHeight: undefined,
    unit: undefined,
    orderSpecification: undefined,
    orderQuantity: undefined,
    sparePartsQuantity: undefined,
    productionQuantity: undefined,
    pieceAttachmentMethod: undefined,
    isCustomerSpecialPrice: undefined,
    areaQuotation: undefined,
    unitPrice: undefined,
    volume: undefined,
    productionPlanQuantity: undefined,
    warehouseInQuantity: undefined,
    deliveryQuantity: undefined,
    printColor: undefined,
    quotationId: undefined,
    quotationNo: undefined,
    productionLength: undefined,
    productionWidth: undefined,
    productionHeight: undefined,
    productionSpecification: undefined,
    crossCuttingVersionNo: undefined,
    isApproved: undefined,
    area: undefined,
    isTerminated: undefined,
    packagingQuantity: undefined,
    remark: undefined,
    isFinalized: undefined,
    isPrinted: undefined,
    productionRemark: undefined,
    innerOuterDiameter: undefined,
    flangeType: undefined,
    dieCuttingCalculation: undefined,
    templateWidth: undefined,
    templateLength: undefined,
    modulus: undefined,
    outsourcing: undefined,
    productType: undefined,
    specialColor: undefined,
    machine: undefined,
    nailingMethod: undefined,
    adhesionMethod: undefined,
    packagingMethod: undefined,
    accessories: undefined,
    foldingNumber: undefined,
    laminationType: undefined,
    deliveryMethod: undefined,
    leaveVersion: undefined,
    ctp: undefined,
    newDiemold: undefined,
    oldDiemold: undefined,
    surfaceTreatment: undefined,
    productionProcess: undefined,
    customerPo: undefined,
    cutCorners: undefined,
    proportionQuantity: undefined,
    productUnit: undefined,
    subcomponent: undefined,
    serialNo: undefined,
    projectNo: undefined,
    customerMaterial: undefined,
    productDescription: undefined,
    productRemark1: undefined,
    productRemark2: undefined,
    productRemark3: undefined,
    productRemark4: undefined,
    productRemark5: undefined,
    stapleBar: undefined,
    addPoints: undefined,
    isExternalPurchase: undefined,
    productionProcess2: undefined,
    sets: undefined,
    thickness: undefined,
    unitWeight: undefined,
    isHeavenBox: undefined,
    heavenBoxHeight: undefined,
    heavenBoxLength: undefined,
    heavenBoxWidth: undefined,
    amount: undefined,
    setId: undefined,
    setName: undefined,
    mainItemId: undefined,
    mainItemName: undefined,
    otherRemark: undefined,
    sizeSegment: undefined,
    multipleModelTypes: undefined,
    content: undefined,
    printColor2: undefined,
    process: undefined,
    other: undefined,
    templateWidth2: undefined,
    templateLength2: undefined,
    modulus2: undefined,
    customerManualOrderNo: undefined,
    totalArea: undefined,
    packagingMethod2: undefined,
    additionalCost: undefined,
    parameter1: undefined,
    parameter2: undefined,
    parameter3: undefined,
    parameter4: undefined,
    parameter5: undefined,
    parameter6: undefined,
    parameter7: undefined,
    parameter8: undefined,
    parameter9: undefined,
    parameter10: undefined,
    isSameModel: undefined,
    orderNumber: undefined,
    bomSequenceNumber: undefined,
    bomLevel: undefined,
    unshippedQuantity: undefined,
    unsentQuantity: undefined,
    totalVolume: undefined,
    printVersionNo: undefined,
    bomRecalculation: undefined,
    materialTypeId: undefined,
    materialType: undefined,
    completionOfVersion: undefined,
    addLoss: undefined,
    parameter11: undefined,
    parameter12: undefined,
    parameter13: undefined,
    parameter14: undefined,
    parameter15: undefined,
    parameter16: undefined,
    parameter17: undefined,
    parameter18: undefined,
    parameter19: undefined,
    parameter20: undefined,
    unitPriceAdditionalFee: undefined,
    paperboardOrderNo: undefined,
    paperboardOrderId: undefined,
    wechatPush: undefined,
    costPrice: undefined,
    areaCostPrice: undefined,
    discount: undefined,
    grossBoardWeight: undefined,
    useInventory: undefined,
    sparePartsPercentage: undefined,
    profitMargin: undefined,
    discountPrice: undefined,
    areaUnitPrice: undefined,
    totalWeight: undefined,
    unitPriceMarkup: undefined,
    customWeight: undefined,
    tag1: undefined,
    tag2: undefined,
    tag3: undefined,
    tag4: undefined,
    tag5: undefined,
    deliveryAddress: undefined,
    deliveryRegion: undefined,
    quantity: undefined,
    additionalCostUnitPrice: undefined,
    rawMaterialCostRatio: undefined,
    squarePriceDifference: undefined,
    fullPage: undefined,
    splitPage: undefined,
    oldVersion: undefined,
    oldModified: undefined,
    newVersion: undefined,
    flatRolling: undefined,
    roundRolling: undefined,
    oldDieCutting: undefined,
    oldDieCuttingModified: undefined,
    newDieCutting: undefined,
    choice1: undefined,
    choice2: undefined,
    choice3: undefined,
    choice4: undefined,
    noUploadFile: undefined,
    downSpreadAreaUnitPrice: undefined,
    pressLine: undefined,
    verticalPressLine: undefined,
    financialApproval: undefined,
    financialApprovalTime: undefined,
    financialApprover: undefined
  }
  formRef.value?.resetFields()
}


// ** 客户 & 材质列表 ** 
const customerList = ref<{ id: string; name: string ; number: string}[]>([])
const materialList = ref<{ id: string; materialName: string }[]>([])
const productMaterialList = ref<{ id: string; materialName: string }[]>([])
const boxTypeList = ref<{ id: string; productTypeName: string }[]>([])

/** 获取客户列表 */
const getAllBaseCustomer = async () => {
  try {
    const response = await SaleBomApi.getAllBaseCustomer();
    if (response) {
      customerList.value = response;
    }
  } catch (error) {
    console.error("获取客户列表失败:", error);
  }
};
/** 获取箱型 */
const getAllBoxType = async () => {
  try {
    const response = await SaleBomApi.getAllBaseBoxType();
    if (response) {
      boxTypeList.value = response;
    }
  } catch (error) {
    console.error("获取箱型列表失败:", error);
  }
};

/** 获取材质列表 */
const getAllBaseMaterial = async () => {
  try {
    const response = await SaleBomApi.getAllBaseMaterial();
    if (response) {
      materialList.value = response;
    }
  } catch (error) {
    console.error("获取材质列表失败:", error);
  }
}; 

/** 选择客户时，自动填充客户名称 */
const handleCustomerChange = (id: string) => {
  const selectedCustomer = customerList.value.find(item => item.id === id);
  formData.value.customerId = selectedCustomer ? selectedCustomer.id : "";
  formData.value.customerNumber = selectedCustomer ? selectedCustomer.number : "";
  formData.value.customerName = selectedCustomer ? selectedCustomer.name : "";
};

/** 选择客户时，自动填充客户名称 */
const handleBoxTypeChange = (id: string) => {
  const selectedBoxType = boxTypeList.value.find(item => item.id === id);
  formData.value.boxTypeName = selectedBoxType ? selectedBoxType.productTypeName : "";
};

/** 选择材质时，自动填充材质名称 */
const handleMaterialChange = (id: string) => {
  const selectedMaterial = materialList.value.find(item => item.id === id);
  formData.value.materialName = selectedMaterial ? selectedMaterial.materialName : "";
};

/** 选择生产材质时，自动填充材质名称 */
const handleProductMaterialChange = (id: string) => {
  const selectedMaterial = materialList.value.find(item => item.id === id);
  formData.value.productionMaterialName = selectedMaterial ? selectedMaterial.materialName : "";
};

onMounted(() => {
  Promise.all([
    getAllBaseCustomer(), // 获取所有客户
    getAllBaseMaterial(),  // 获取所有材质
    getAllBoxType() // 获取所有箱型
  ])
})
</script>